#pragma once
#include "output_document.h"
#include "merger_cache.h"
#include <istream>

namespace Pdf
{
	class Merger : public OutputDocument
	{
	public:
		Merger(std::ostream &output);
		~Merger();

		void						append(std::istream &path, const std::string &password);

	private:
        class Inserter;

		typedef std::map<StreamInfo, Reference::Value>			StreamCache;
		typedef std::map<FontInfo, Reference::Value>			FontCache;

		Reference::Value			getNextID();

		Reference::Ptr				catalogRef;
		Reference::Ptr				pageRootRef;
		ArrayFactory				kidsFactory;
		StreamCache					streamCache;
		FontCache                   fontCache;
	};
}